<div class="tab-pane fade in active show" id="tab-user-auth" role="tabpanel" aria-labelledby="tab-user-auth">
  <div class="card mb-4">
    <div class="card-header d-flex fs-5">
      <button class="btn d-md-none flex-grow-1 text-start" data-bs-target="#collapse-tab-user-auth" data-bs-toggle="collapse" aria-controls="collapse-tab-user-auth">
        {{ lang.user.mailbox_general }}
      </button>
      <span class="d-none d-md-block">{{ lang.user.mailbox_general }}</span>
    </div>
    <div id="collapse-tab-user-auth" class="card-body collapse" data-bs-parent="#user-content">
      {% if mailboxdata.attributes.force_pw_update == '1' %}
        <div class="alert alert-danger">{{ lang.user.force_pw_update|raw }}</div>
      {% endif %}
      <div class="row">
        <div class="col-xl-9 col-lg-7 col-md-12 col-12 d-flex flex-column mb-4">
          {% if not skip_sogo %}
          <div class="row mb-4">
            <div class="col-12 col-lg-6 col-xl-4">
              {% if dual_login and allow_admin_email_login == 'n' or mailboxdata.attributes.force_pw_update == '1' %}
                <button disabled class="btn btn-secondary btn-block btn-xs-lg w-100">
                  {{ lang.user.open_webmail_sso }} <i class="bi bi-arrow-right"></i>
                </button>
              {% elseif dual_login %}
                <a href="/sogo-auth.php?login={{ mailcow_cc_username  }}" role="button" class="btn btn-primary btn-lg btn-block btn-xs-lg w-100">
                  {{ lang.user.open_webmail_sso }} <i class="bi bi-arrow-right"></i>
                </a>
              {% else %}
                <a href="/SOGo/so" role="button" class="btn btn-primary btn-lg btn-block btn-xs-lg w-100">
                  {{ lang.user.open_webmail_sso }} <i class="bi bi-arrow-right"></i>
                </a>
              {% endif %}
            </div>
          </div>
          {% endif %}

          <legend>{{ lang.user.overview }}</legend>
          <hr>
          <div class="d-flex">
            <h5><i class="bi bi-envelope-fill"></i> {{ mailboxdata.messages }} {{ lang.user.messages }}</h5>
            <h5 class="ms-auto">{{ mailboxdata.quota_used|formatBytes(2) }} / {% if mailboxdata.quota == 0 %}∞{% else %}{{ mailboxdata.quota|formatBytes(2) }}{% endif %}</h5>
          </div>
          <div class="progress mb-4" style="height: 20px";>
            <div class="progress-bar bg-{{ mailboxdata.percent_class }}" role="progressbar" aria-valuenow="{{ mailboxdata.percent_in_use }}" aria-valuemin="0" aria-valuemax="100" style="min-width:2em;width: {{ mailboxdata.percent_in_use }}%;">
              {{ mailboxdata.percent_in_use }}%
            </div>
          </div>

          <div class="row">
            <div class="col-12 col-md-3 d-flex">
              <span class="mt-2 w-100 text-md-end">{{ lang.user.protocols }}:</span>
            </div>
            <div class="col-12 col-md-9 d-flex">
              <i style="font-size: 16px; cursor: pointer;" class="bi bi-patch-question-fill m-2 ms-0" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" title="{{ lang.user.direct_protocol_access|raw }}"></i>
              <div class="d-flex flex-wrap">
              {% if mailboxdata.attributes.imap_access == 1 %}<div class="badge fs-6 bg-success m-2">IMAP <i class="bi bi-check-lg"></i></div>{% else %}<div class="badge fs-6 bg-danger m-2">IMAP <i class="bi bi-x-lg"></i></div>{% endif %}
              {% if mailboxdata.attributes.smtp_access == 1 %}<div class="badge fs-6 bg-success m-2">SMTP <i class="bi bi-check-lg"></i></div>{% else %}<div class="badge fs-6 bg-danger m-2">SMTP <i class="bi bi-x-lg"></i></div>{% endif %}
              {% if mailboxdata.attributes.sieve_access == 1 %}<div class="badge fs-6 bg-success m-2">Sieve <i class="bi bi-check-lg"></i></div>{% else %}<div class="badge fs-6 bg-danger m-2">Sieve <i class="bi bi-x-lg"></i></div>{% endif %}
              {% if mailboxdata.attributes.pop3_access == 1 %}<div class="badge fs-6 bg-success m-2">POP3 <i class="bi bi-check-lg"></i></div>{% else %}<div class="badge fs-6 bg-danger m-2">POP3 <i class="bi bi-x-lg"></i></div>{% endif %}
              </div>
            </div>
          </div>
          <div class="row mt-2">
            <div class="col-12 col-md-3 d-flex">
              <span class="mt-2 w-100 text-md-end">{{ lang.user.apple_connection_profile }}:</span>
            </div>
            <div class="col-12 col-md-8">
              <div class="d-flex">
                <i style="font-size: 16px; cursor: pointer;" class="bi bi-patch-question-fill me-2" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" title="{{ lang.user.apple_connection_profile_mailonly }}"></i>
                <a href="/mobileconfig.php?only_email">{{ lang.user.email }} <small>[IMAP, SMTP]</small></a>
              </div>
              {% if not skip_sogo %}
              <div class="d-flex">
                <i style="font-size: 16px; cursor: pointer;" class="bi bi-patch-question-fill me-2" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" title="{{ lang.user.apple_connection_profile_complete }}"></i>
                <a href="/mobileconfig.php">{{ lang.user.email_and_dav }} <small>[IMAP, SMTP, Cal/CardDAV]</small></a>
              </div>
              {% endif %}
            </div>
          </div>
          <div class="row mt-2">
            <div class="col-12 col-md-3 d-flex">
              <span class="mt-2 w-100 text-md-end">{{ lang.user.apple_connection_profile }}<br>{{ lang.user.with_app_password }}:</span>
            </div>
            <div class="col-12 col-md-9">
              <div class="d-flex">
                <i style="font-size: 16px; cursor: pointer;" class="bi bi-patch-question-fill me-2" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" title="{{ lang.user.apple_connection_profile_mailonly }} {{ lang.user.apple_connection_profile_with_app_password }}"></i>
                <a href="/mobileconfig.php?only_email&amp;app_password">{{ lang.user.email }} <small>[IMAP, SMTP]</small></a>
              </div>
              {% if not skip_sogo %}
              <div class="d-flex">
                <i style="font-size: 16px; cursor: pointer;" class="bi bi-patch-question-fill me-2" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" title="{{ lang.user.apple_connection_profile_complete }} {{ lang.user.apple_connection_profile_with_app_password }}"></i>
                <a href="/mobileconfig.php?app_password">{{ lang.user.email_and_dav }} <small>[IMAP, SMTP, Cal/CardDAV]</small></a>
              </div>
              {% endif %}
            </div>
          </div>
          <div class="row">
            <div class="col-12 d-flex flex-column text-center align-items-center mt-4">
              <a target="_blank" href="https://mailcow.github.io/mailcow-dockerized-docs/client/client/#{{ clientconfigstr }}">{{ lang.user.client_configuration }}</a>
              <a class="mt-2" href="#userFilterModal" data-bs-toggle="modal">{{ lang.user.show_sieve_filters }}</a>
            </div>
          </div>

          {% if mailboxdata.authsource == "mailcow" %}
          <legend class="mt-4">{{ lang.user.authentication }}</legend>
          <hr>
          {# Password Change #}
          <div class="row">
            <div class="col-12 col-md-3 d-flex"></div>
            <div class="col-12 col-md-9 d-flex flex-wrap">
              <a class="btn btn-secondary" href="#pwChangeModal" data-bs-toggle="modal"><i class="bi bi-pencil-fill"></i> {{ lang.user.change_password }}</a>
              {% if acl.pw_reset == 1 %}
              <a class="btn btn-secondary ms-4" href="#pwRecoveryEmailModal" data-bs-toggle="modal"><i class="bi bi-pencil-fill"></i> {{ lang.user.pw_recovery_email }}</a></p>
              {% endif %}
            </div>
          </div>
          {% endif %}
          {# TFA #}
          {% if mailboxdata.authsource == "mailcow" or mailboxdata.authsource == "ldap" %}
          <div class="row mt-4">
            <div class="col-12 col-md-3 d-flex">
              <span class="mt-2 w-100 text-md-end">{{ lang.tfa.tfa }}:</span>
            </div>
            <div class="col-12 col-md-9 d-flex flex-wrap justify-content-center justify-content-sm-start">
              <span id="tfa_pretty">{{ tfa_data.pretty }}</span>
              {% include 'tfa_keys.twig' %}
            </div>
          </div>
          <div class="row mt-2 mb-4">
            <div class="col-12 col-md-3 d-flex">
              <span class="mt-2 w-100 text-md-end">{{ lang.tfa.set_tfa }}:</span>
            </div>
            <div class="col-12 col-md-9 d-flex flex-wrap align-items-center justify-content-center justify-content-sm-start">
              <i style="font-size: 16px; cursor: pointer;" class="bi bi-patch-question-fill m-2 ms-0" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="bottom" title="{{ lang.user.tfa_info|raw }}"></i>
              <select data-style="ms-2 btn btn-sm dropdown-toggle bs-placeholder btn-secondary" data-width="fit" id="selectTFA" class="selectpicker" title="{{ lang.tfa.select }}">
                <option value="yubi_otp">{{ lang.tfa.yubi_otp }}</option>
                <option value="webauthn">{{ lang.tfa.webauthn }}</option>
                <option value="totp">{{ lang.tfa.totp }}</option>
                <option value="none">{{ lang.tfa.none }}</option>
              </select>
            </div>
          </div>
          {% endif %}
          {# FIDO2 #}
          {% if mailboxdata.authsource == "mailcow" %}
          <div class="row mt-4">
            <div class="col-sm-3 col-12 text-sm-end text-start">
              <p><i class="bi bi-shield-fill-check"></i> {{ lang.fido2.fido2_auth }}</p>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-3 col-12 text-sm-end text-start mb-4">
              {{ lang.fido2.known_ids }}:
            </div>
            <div class="col-sm-9 col-12">
              <div class="table-responsive">
                <table class="table table-striped table-hover table-condensed" id="fido2_keys">
                  <tr>
                    <th>ID</th>
                    <th style="min-width:240px;text-align: right">{{ lang.admin.action }}</th>
                  </tr>
                  {% include 'fido2.twig' %}
                </table>
              </div>
              <br>
            </div>
          </div>
          <div class="row">
            <div class="offset-sm-3 col-sm-9">
              <div class="btn-group nowrap">
                <button class="btn btn-sm btn-primary d-block d-sm-inline" id="register-fido2">{{ lang.fido2.set_fido2 }}</button>
                <button type="button" class="btn btn-sm btn-xs-lg btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
                <ul class="dropdown-menu">
                  <li><a class="dropdown-item" href="#" id="register-fido2-touchid"><i class="bi bi-apple"></i> {{ lang.fido2.set_fido2_touchid }}</a></li>
                </ul>
              </div>
            </div>
          </div>
          <br>
          <div class="row" id="status-fido2">
            <div class="col-sm-3 col-5 text-end">{{ lang.fido2.register_status }}:</div>
            <div class="col-sm-9 col-7">
              <div id="fido2-alerts">-</div>
            </div>
            <br>
          </div>
          {% endif %}
        </div>
        <div class="ms-auto col-xl-3 col-lg-5 col-md-12 col-12 d-flex flex-column well flex-grow-1" id="recent-logins">
          <legend class="d-flex">
            <span>{{ lang.user.recent_successful_connections }}</span>
            <div id="spinner-last-login" class="ms-auto my-auto spinner-border spinner-border-sm d-none" role="status">
              <span class="visually-hidden">Loading...</span>
            </div>
          </legend>
          <hr>
          <div class="d-flex">
            <span class="clear-last-logins mt-auto mb-2">
              {{ lang.user.clear_recent_successful_connections }}
            </span>
            <div class="dropdown mt-4 mb-2 ms-auto">
              <button class="btn btn-secondary btn-xs btn-xs-lg dropdown-toggle" type="button" id="history_sasl_days" data-bs-toggle="dropdown">{{ lang.user.login_history }}</button>
              <ul class="dropdown-menu">
                <li class="login-history" data-days="1"><a class="dropdown-item" href="#">1 {{ lang.user.day }}</a></li>
                <li class="login-history" data-days="7"><a class="dropdown-item active" href="#">1 {{ lang.user.week }}</a></li>
                <li class="login-history" data-days="14"><a class="dropdown-item" href="#">2 {{ lang.user.weeks }}</a></li>
                <li class="login-history" data-days="31"><a class="dropdown-item" href="#">1 {{ lang.user.month }}</a></li>
              </ul>
            </div>
          </div>
          <ul class="list-group last-sasl-login overflow-auto" style="flex: 1 1 0; min-height: 400px;"></ul>
        </div>
      </div>
    </div>
  </div>
</div>
